/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package javaapplication1;

import filereader.FileListing;
import filereader.MessageReader;
import java.io.File;
import java.util.List;

/**
 *
 * @author Danang
 */
public class MailParser_Tmp {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws Exception {
        if (args.length<1)
            throw new Exception("Arguments must be two words of : <database_dir>");
        System.out.println("Data mail direcroty : "+args[0]);
        
        // catat waktu mulai
        long start_time = System.currentTimeMillis(), execution_time;
        // secara rekursif dapatkan list file
        List<File> fileList = FileListing.getFileListing(new File(args[0]));
        printExecution_time(System.currentTimeMillis()-start_time);
        
        MessageReader mr = new MessageReader(fileList);
        // jalankan reader
        mr.run();
        mr.terminate();
        
        // hitung waktu eksekusi dan print ke layar
        execution_time = System.currentTimeMillis()-start_time;
        printExecution_time(execution_time);   
    }
    
     // print execution time
    static public void printExecution_time(long exec) {
        int minute = (int) ((exec/1000)/60);
        int seconds = (int) ((exec/1000)%60);
        int miliseconds = (int) (exec%1000);
        System.out.println("Execution time "+minute+" minutes "+seconds+" seconds "+miliseconds+ " ms.");
    }
}
